package component.titan.custom.serializer

import com.thinkaurelius.titan.core.attribute.AttributeSerializer
import com.thinkaurelius.titan.diskstorage.{ScanBuffer, WriteBuffer}
import com.thinkaurelius.titan.graphdb.database.serialize.attribute.LongSerializer
import org.joda.time.DateTime

/**
  * Created by lovepocky on 16/7/5.
  */
class JodaDateTimeSerializer extends AttributeSerializer[DateTime] {

	val serializer = new LongSerializer()

	override def write(buffer: WriteBuffer, attribute: DateTime): Unit = {
		serializer.write(buffer,attribute.getMillis)
	}

	override def read(buffer: ScanBuffer): DateTime = {
		new DateTime(serializer.read(buffer))
	}
}
